//
//  MyCollectionViewCell.m
//  UI 豆瓣完整版
//
//  Created by dllo on 16/1/7.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "MyCollectionViewCell.h"
#import "Model.h"
#import "UIImageView+WebCache.h"

@interface MyCollectionViewCell ()


@property (nonatomic, retain) UILabel *nameLabel;

@end


@implementation MyCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)dealloc {
    [_nameLabel release];
    [_imgView release];
    [super dealloc];
}

- (void)setModel:(Model *)model {
    if (_model != model) {
        [_model release];
        _model = [model retain];
       
    }
     [self fuZhi];
}

- (void)fuZhi {
    _nameLabel.text = _model.original_title;


}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    _imgView.backgroundColor = [UIColor purpleColor];
    _imgView.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height - 30);
    _nameLabel.frame = CGRectMake(0, layoutAttributes.frame.size.height - 30, layoutAttributes.frame.size.width, 30);
//    _nameLabel.alpha = 0.5;
    _nameLabel.backgroundColor = [UIColor whiteColor];
}
                                                                                                                                                                                                                                                                                              
- (void)createSubViews {
    self.imgView = [[UIImageView alloc] init];
    [self.contentView addSubview:_imgView];
    [_imgView release];
    _imgView.backgroundColor = [UIColor redColor];
    
    self.nameLabel = [[UILabel alloc] init];
    _nameLabel.textColor = [UIColor blackColor];
    _nameLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_nameLabel];
    [_nameLabel release];
    _nameLabel.backgroundColor = [UIColor cyanColor];
    
}

@end
